package com.yuliang.utils.superbackage;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @author Huangkai
 */
@Data
public class SuperEntity<T extends Model> extends Model {
    private static final long serialVersionUID = -4851055162892178225L;

    /**
     * 状态 0：失效  1：生效
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * uuid
     */
    @TableId("uuid")
    private String uuid;
    /**
     * 0表示不删除，1表示删除
     * */
    @TableLogic(value = "0", delval = "1")
    @TableField("flag")
    private Integer flag;
    /**
     * @TableField 配置需要填充的字段
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date createTime;

    /**
     * 更新时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    public SuperEntity() {
        this.flag = 0;
        this.createTime = new Date();
        this.updateTime = new Date();
    }
}
